var ws,uid,type_id,cur_page;
var resArry=[];
cur_page = 1;
nomore = false;
var app = angular.module('app',[]);
app.controller('my_controller',function($scope,$http){
	$scope.intview = function(){
	if(nomore){return;}	
	$http({
		method:'post',
		url:apiRoot,
		data:{
			action:'Merchant.checkMerchantStatus',
			uid:uid,
			page:cur_page
		}
	}).then(function success(result){	
		$scope.res = result.data.data;   
		$scope.picture = result.data.data.photo;
	},function errorFunction(e){
		console.log(JSON.stringify(e));
	})

	//卖主商品
	$http({
		method:'post',
		url:apiRoot,
		data:{
			action:'Goods.getSomeoneGoods',
			uid:uid,
			page:cur_page
			}
	}).then(function successCallback(response){ 
		if(response.data.data == undefined){
			$scope.not_more  = 1;
			nomore = true;
			return; 
		}
		resArry.push(response.data.data);
		$scope.all_goods = resArry;
		cur_page++;
	},function errorfunction(e){	
		console.log(e); 
	})
	
		//获取登录用户的ID   在页面用
		$scope.mySelf_id = plus.storage.getItem('uid');
	}
	
	
	//卖家资质
	$scope.open_salerAptitude =function(id){
		plus.webview.create('saler_aptitude.html', 'saler_aptitude.html',{},{uid:id}).show('pop-in');
	}
	
	//个人主页 
	$scope.open_honerPage =function(id,type_id){
		plus.webview.create('honer_page.html', 'honer_page.html',{},{icon_id:id,type_id:type_id}).show('pop-in');
	}
	
	//商品详情
	$scope.open_goodsDetail=function(id,type,uid){
		plus.webview.create('goods_detail.html', 'goods_detail.html',{},{gId:id,type:type,gUid:uid}).show('pop-in');    
	}
	
})



document.addEventListener('plusready',function(){
	ws = plus.webview.currentWebview();
	uid = ws.uid;
	type_id = ws.type_id;
	appElement = document.querySelector('[ng-controller=my_controller]');
	$scope = angular.element(appElement).scope();
	$scope.intview();
	$scope.$apply();
})